cmake_minimum_required(VERSION 3.10)

project(cmake-example VERSION 1.0)

option(USE_MYMATH "Use tutorial provided math implementation" ON)

configure_file(main.h.in main.h)

set(src ${CMAKE_CURRENT_SOURCE_DIR}/main.c)

add_executable(example ${src})

if(USE_MYMATH)
    add_subdirectory(cmatch)
    list(APPEND EXTRA_LIBS cmatch)
    list(APPEND EXTRA_INCLUDES "${PROJECT_SOURCE_DIR}/cmatch")
endif()

target_link_libraries(example PUBLIC ${EXTRA_LIBS})

target_include_directories(example PUBLIC
                          "${PROJECT_BINARY_DIR}"
                          ${EXTRA_INCLUDES}
                        )

message("打印 ${PROJECT_BINARY_DIR}")
message("打印 ${PROJECT_SOURCE_DIR}/cmatch")